# try except 中间的变量 , 外边可以使用
# try except 不可切割变量作用域

# if:
#   a= 3
# print(a)
#  循环语句

# 函数 和 类 切割了变量的作用域
#  a
#  NameError : name 'a' is not defind

# dict = {}, dict['a']
# KeyError : 'a'

# 10/0

# list1
# IndexError: list index out of range

#  Exception 是所有异常的父类

try:
    list1 = [1,2,3]
    list1[3]
# except (NameError,KeyError,IndexError) as e: # except 异常名(Exception) as 返回值(异常的详细信息)
#     print(e)
#     print('111')
except (Exception,KeyError,IndexError) as e:
    print(e)
    print(type(e))   #   <class 'IndexError'>

print('异常下方代码')